
package com.jz.aspectj.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import org.springframework.core.annotation.AnnotationUtils;


public class Attribute {
	private String managerName;
	private String methodName;
	
	public static Attribute findAttribute(Method method) {
		Annotation[] annotations = AnnotationUtils.getAnnotations(method);
		
		if (annotations == null) {
			return null;
		}
		Attribute attr = new Attribute();
		for (int i = 0; i < annotations.length; i++) {
			Annotation annotation = annotations[i];
			if (annotation instanceof Lazyload) {
				Lazyload lazy = (Lazyload) annotation;
				attr.setManagerName(lazy.manager());
				attr.setMethodName(lazy.method());
				break;
			} 
		}
		if (attr != null) {
			return attr;
		}
		return null;
	}

	public String getManagerName() {
		return managerName;
	}

	public void setManagerName(String managerName) {
		this.managerName = managerName;
	}

	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}
}
